﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationProtocol.dto.command.client
{
    public class LoginRequest:Command
    {
        public LoginRequest(string v):base(4)
        {
            
            V = v;
        }

        public LoginRequest(byte[] bytes):base(4)
        {
            V = Encoding.UTF8.GetString(bytes,4,BitConverter.ToInt32(bytes,0));
        }

        public string V { get; }

        public override byte[] GetBytes()
        {
            var data = Encoding.UTF8.GetBytes(V);
            return new byte[] { functionCode}
            .Concat(BitConverter.GetBytes( data.Length))
            .Concat(data)
            .ToArray();
        }
    }
}
